#pragma once

#include <string>
#include <list>

struct NPEnumEntry {
    DWORD mDisplayType{};
    DWORD mScope{};
    DWORD mType{};
    DWORD mUsage{};
    std::wstring mLocalName;
    std::wstring mRemoteName;
    std::wstring mComment;
    std::wstring mProvider;

    NPEnumEntry()
    { ; }

    NPEnumEntry(DWORD dwScope, DWORD dwType, DWORD dwDisplayType, DWORD dwUsage,
                LPCWSTR localName, LPCWSTR remoteName, LPCWSTR comment, LPCWSTR provider)
        : mDisplayType(dwDisplayType),
        mScope(dwScope),
        mType(dwType),
        mUsage(dwUsage),
        mLocalName(localName ? localName : L""),
        mRemoteName(remoteName ? remoteName : L""),
        mComment(comment ? comment : L""),
        mProvider(provider ? provider : L"")
        { ; }

    // Fills ResInfo.
    // Takes size of the buffer on input
    // returns num of bytes copied on success
    //     or num of bytes required if info doesn't fit
    // We place strings at the end of the buffer,
    //     because we must form data that starts with fixed array of NETRESOURCE
    ULONG FillResourceInfo(LPNETRESOURCE pResInfo, UCHAR **ppStringsEndPtr, ULONG size);
};

class NPEnum {
    DWORD mScope;
    DWORD mType;
    DWORD mUsage;
    bool  mIsRootResource;

    typedef std::list<NPEnumEntry> ResList;

    ResList           mResourceList;
    ResList::iterator mResourcesListIterator;

    DWORD createHostEntry();
    DWORD createConnectedList();
    DWORD createGlobalNetList();
    DWORD createSharedFoldersList(); // list of shared folders

public:
    NPEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource);

    DWORD EnumerateResources();
    DWORD FillResourceRequest(ULONG* pCount, VOID* pBuf, ULONG* pBufSize);
};
